EMT Practice Test

1. Question Content...


Question List

Question1: What data structure is used to store the newly created index in MongoDB?

Question2: Which collection method do you need to use to drop a specific collection?

Question3: What is the built-in database called config in MongoDB for?

Question4: You have a developers collection with the following document structure: { _id: 1, fname: 'John', lname: 'Smith', tech_stack: ['sql', 'git', 'python', 'linux', 'django', 'aws'] }, { _id: 2, fname: 'Michael', lname: 'Doe', tech_stack: [ 'git', 'python', 'sqlite', 'linux', 'flask' ] } Which of the following queries will return only the first three elements of the array in the tech_stack field?

Question5: You have the following config file: storage: dbPath: /data/db systemLog: destination: file path: /var/log/mongod.log net: bindIp: localhost,192.168.168.62 security: keyFile: /var/pki/keyfile processManagement: fork: true Select all the directories that MongoDB must have access to

Question6: Which cursor method should you use to get information about the query plan?

Question7: Select all true statements about MongoDB documents.

Question8: Which of the following actions are granted to the built-in readWrite role?

Question9: Suppose you have the following index on a routes collection: db.routes.createIndex( { airplane: 1, src_airport: 1, dst_airport: 1, stops: 1 } ) Which of the following queries will be able to use this index for sorting. Check all that apply.

Question10: Why is MongoDB using BSON instead of JSON to store data? Select all that apply.

Question11: There is a gamers collection in your database with the following document structure:
{ _id: 1, level: 15, is_active: true }, { _id: 2, level: 14, is_active: true }, { _id: 3, level: 7, is_active: false }
How do you update the value of the level field to 20 for a player with an id = 2?
Expected result:
{ _id: 1, level: 15, is_active: true }, { _id: 2, level: 20, is_active: true }, { _id: 3, level: 7, is_active: false }

Question12: Suppose we have database with the following collections: db.users.insertMany([ { _id: 1, user_name: 'karo243', account_id: 1010 }, { _id: 2, user_name: 'jano23', account_id: 3213 }, { _id: 3, user_name: 'fac_data', account_id: 4336 } ]) db.accounts.insertMany([ { account_id: 1010, type: 'investment', limit: 1000000 }, { account_id: 4336, type: 'derivatives', limit: 100000 } ]) We want to perform so-called left join. To the users collection join account details from accounts collection based on account_id field. See below. Expected output: [ { _id: 1, user_name: 'karo243', account_id: 1010, account_details: [ { _id: ObjectId("61af47c6e29861661d063714"), account_id: 1010, type: 'investment', limit: 1000000 } ] }, { _id: 2, user_name: 'jano23', account_id: 3213, account_details: [] }, { _id: 3, user_name: 'fac_data', account_id: 4336, account_details: [ { _id: ObjectId("61af47c6e29861661d063715"), account_id: 4336, type: 'derivatives', limit: 100000 } ] } ]
Which query do you need to use?

Question13: Which of the following commands will add a collection that is stored in BSON file to a MongoDB cluster?

Question14: How many indexes will the following command create?
db.products.createIndex( { product_name: 1, product_category: -1 } )

Question15: Select all true statements about replication in MongoDB.

Question16: Suppose you are connected to mongod instance that is already running on port 27000 as admin user. You have to export reviews collection from the restaurants database to JSON file named reviews.json. Which command should you use?

Question17: Use case: e-learning platform Which of the following scenarios is the best candidate to use the Extended Reference Pattern to avoid additional reads by joins/lookups?

Question18: Select all true statements regarding to Aggregation Framework.

Question19: Suppose you are connected to mongod instance that is already running on port 27000 as admin user. You have to dump reviews collection from the restaurants database to BSON file. Which command should you use?

Question20: Select all true statements about covered queries.

Question21: In your database there is a movies collection with the following document structure: { _id: ObjectId("573a1390f29313caabcd42e8"), genres: [ 'Short', 'Western' ], title: 'The Great Train Robbery', rated: 'TV-G', year: 1903, imdb: { rating: 7.4, votes: 9847, id: 439 }, countries: [ 'USA' ] }, { _id: ObjectId("573a1390f29313caabcd4323"), genres: [ 'Short', 'Drama', 'Fantasy' ], rated: 'UNRATED', title: 'The Land Beyond the Sunset', year: 1912, imdb: { rating: 7.1, votes: 448, id: 488 }, countries: [ 'USA' ] } In some documents, where there is no rating information for movie, the value is set to '' (empty string). With that in mind, which of the following queries will return the title and rating (see below) of top 3 rated movies in this collection?

Question22: What does it command do in the mongo shell?

Question23: Select all true statements about reconfiguring a replica set with rs.reconfig().

Question24: Suppose you insert the following documents into companies collection: db.companies.insertMany([ {"_id": 1, "name": "Facebook"}, {"_id": 1, "name": "Twitter"}, {"_id": 2, "name": "Tesla"}, {"_id": 3, "name": "Amazon"} ], {"ordered": false}) Select all true statements about this operation. (select 3)

Question25: You have a configuration file for mongod instance called mongod.conf in your working directory. How can you launch mongod instance with this configuration file?

Question26: Suppose you have an accounts collection in your database. Only the following documents are stored in this collection: { _id: ObjectId("61af47c6e29861661d063714"), account_id: 1010, type: 'investment', limit: 2000000 }, { _id: ObjectId("61af47c6e29861661d063715"), account_id: 4336, type: 'derivatives', limit: 100000 }, { _id: ObjectId("61af47c6e29861661d063716"), account_id: 4336, type: 'commodity', limit: 1000 }, { _id: ObjectId("61af47c6e29861661d067825"), account_id: 7355, type: 'commodity', limit: 500000 }, { _id: ObjectId("61b1bde1ceb6f770f56b0cd9"), account_id: 4915, type: 'investment', limit: 2000000 } How many documents will be returned in response to the following aggregation pipeline? [{ $group: { _id: "$type", number_of_accounts: { $sum: 1 } }}, { $match: { number_of_accounts: { $gt: 1 } }}]

Question27: Select all true statements regarding to the insert operation.

Question28: Data modeling. You are considering the use of nesting or the references in your data model. Data read operations must be fast. Which option would be more appropriate?

Question29: A collection called players contains the following documents:
[ { _id: 1, user: 'Tom', scores: [ 23, 56, 3, 52, 62 ], bonus: 5 }, { _id: 2, user: 'Jane', scores: [ 42, 50, 10 ], bonus: 3 } ]
You want to add additional fields to each document:
-> total_score (sum of the scores Array) -> avg_score (average score in scores Array) -> total_score_with_bonus (total_score + bonus) Expected output: [ { _id: 1, user: 'Tom', scores: [ 23, 56, 3, 52, 62 ], bonus: 5, total_score: 196, avg_score: 39.2, total_score_with_bonus: 201 }, { _id: 2, user: 'Jane', scores: [ 42, 50, 10 ], bonus: 3, total_score: 102, avg_score: 34, total_score_with_bonus: 105 } ]
Which query do you need to use?

Question30: We can use REGEX in our queries in MongoDB - JavaScript regular expression syntax.

Question31: Select all true statements regarding to scaling.

Question32: In which situations can we consider sharding?

Question33: Which of the following commands will successfully insert exactly two new documents into an empty companies collection?

Question34: The following capped collection is given: db.createCollection('latest_news', {'capped': true, 'size': 10000, 'max': 3}) [ { _id: ObjectId("61e8007c9b3067e362440a88"), title: 'COVID records broken again as weekend brings nearly 40K new cases' }, { _id: ObjectId("61e800989b3067e362440a89"), title: 'Bitcoin, Ethereum, Dogecoin Face Fresh Round Of Regulatory Scrutiny' }, { _id: ObjectId("61e800d19b3067e362440a8a"), title: 'Where Six Meme Stock Investors Are Now' } ] What the latest_news collection will look like after the following operation?

Question35: Given a movies collection where each document has the following structure: { _id: ObjectId('573a1390f29313caabcd60e4'), genres: [ 'Short', 'Comedy', 'Drama' ], title: 'The Immigrant', year: 1917, imdb: { rating: 7.8, votes: 4680, id: 8133 }, countries: [ 'USA' ] } Which of the following queries will find all movies that were made in 2000 or 2010?

Question36: In your database there is a collection named companies with the following document structure: { name: 'Wize', relationships: [ { is_past: false, title: 'Head of Product', person: { first_name: 'Ethan', last_name: 'Smith', permalink: 'ethan-smith' } }, { is_past: true, title: 'Director, Business Development', person: { first_name: 'Stephanie', last_name: 'Quay', permalink: 'stephanie-quay' } }, { is_past: true, title: 'Sr. Engineer', person: { first_name: 'Stefan', last_name: 'Antonowicz', permalink: 'stefan-antonowicz' } } ] } Which of the following queries should you use to extract all companies that have "Co-Founder" title in relationships field (Array)?

Question37: Suppose you have an accounts collection with the following document structure: { _id: ObjectId("61af47c6e29861661d063714"), account_id: 1010, type: 'investment', limit: 1000000 }, { _id: ObjectId("61af47c6e29861661d063715"), account_id: 4336, type: 'derivatives', limit: 100000 }, { _id: ObjectId("61af47c6e29861661d063716"), account_id: 4336, type: 'commodity', limit: 1000 } Which of the following documents would be modified by this update? db.accounts.updateMany( { "type": "investment" }, { "$set": { "limit": 2000000 } } )

Question38: Select all true statements regarding to schema validation in MongoDB.

Question39: Which of the following roles provides the same read-only privileges as read role on all databases except local and config?

Question40: What is MongoDB Charts?

Question41: What do you mean by collection scan during query execution?

Question42: Use case: e-learning platform Which of the following scenarios is the best candidate to use the Subset Pattern?

Question43: We have the following schema for a movies collection: { _id: ObjectId, title: String, genres: Array, languages: Array, year: 32-bit integer } And the following index on the movies collection: { title: 1 } Which of the following queries will use the given index to perform the sorting stage?

Question44: Which collection method do you need to use to drop a specific collection?

Question45: What stages will cause a merge on the primary shard for a database?

Question46: Suppose you have a developers collection with the following document structure: { _id: 1, fname: 'Bob', lname: 'Smith', tech_stack: [ 'git', 'c++', 'sqlite', 'linux' ] } Select a query that can be executed without errors.

Question47: MongoDB can benefit from adding more RAM to your servers.

Question48: Where is the MongoDB configuration file usually located?

Question49: Let's consider a one-to-many relationship observed between an instructor and the courses he is created on an e-learning platform. We assume that a course can only have one instructor, and an instructor can have multiple courses. Which of the following are the correct ways to represent this one-to-many relationship with a document model in MongoDB?

Question50: How to connect to MongoDB with mongod to localhost running on port 27017?

Question51: Given the following example document from an artists collection: { _id: 5, last_name: 'Maurer', first_name: 'Alfred', year_born: 1868, year_died: 1932, nationality: 'USA' } and the following index: db.artists.createIndex( { "last_name": 1, "nationality": 1 } ) How MongoDB will handle the query below?
db.artists.find( { "last_name": /^B./, "nationality": 'France' } )

Question52: Select all true statements about one-to-zillions relationships (a special case of the one-to-many relationship in MongoDB).

Question53: What is the built-in database called local in MongoDB for?

Question54: Suppose you are connected to mongod instance that is already running on port 27000 as admin user. You have to create a new user for an application that has the readWrite role. Use the db.createUser() command to create a user for data analysis. The requirements for this user are: -> role: read on esmartdata database -> username: dataScientist -> password: ds123sci456 Which command should you use?

Question55: Suppose you have a mobile_games collection with the following document structure:
{ game: "Fishing Clash", company: "Ten Square Games", platforms: ['Android', 'IOS'], ...
release_USA: ISODate("2017-04-09T01:00:00+01:00"),
release_France: ISODate("2017-04-09T01:00:00+01:00"),
release_Italy: ISODate("2017-08-17T01:00:00+01:00"), ... }
You want to redesign your document structure as below:
{ game: "Fishing Clash", company: "Ten Square Games", platforms: ['Android', 'IOS'],
releases: [ { location: "USA", date: ISODate("2017-04-09T01:00:00+01:00") },
{ location: "France", date: ISODate("2017-04-09T01:00:00+01:00") },
{ location: "Italy", date: ISODate("2017-08-17T01:00:00+01:00") }, ], }
Which pattern solution will you use to solve this problem?

Question56: You have to launch a replica set with three members. For the first node you have the following mongo1.conf configuration file: storage: dbPath: /var/mongodb/db/1 net: bindIp: localhost port: 27000 security: authorization: enabled systemLog: destination: file path: /var/mongodb/logs/mongod1.log logAppend: true processManagement: fork: true Update this configuration file so that this mongod instance: -> authenticates internally using the keyfile /var/mongodb/pki/keyfile -> belongs to the replica set repl-set-1 Which of the following configuration file should you choose?

Question57: The greater the cardinality of a field, the...

Question58: We have an accounts collection with the following document structure: { _id: ObjectId("5ca4bbc7a2dd94ee5816239d"), account_id: 864905, limit: 10000, products: [ 'Commodity', 'InvestmentStock' ] }, { _id: ObjectId("5ca4bbc7a2dd94ee5816239e"), account_id: 299072, limit: 10000, products: [ 'InvestmentFund', 'InvestmentStock' ] }, { _id: ObjectId("5ca4bbc7a2dd94ee5816239f"), account_id: 137994, limit: 10000, products: [ 'CurrencyService', 'InvestmentStock' ] } We need to use Aggregation Framework to find the distribution of products field. Sort the result set by decreasing total number of products. Expected output: [ { _id: 'InvestmentStock', total: 1746 }, { _id: 'CurrencyService', total: 742 }, { _id: 'Brokerage', total: 741 }, { _id: 'InvestmentFund', total: 728 }, { _id: 'Commodity', total: 720 }, { _id: 'Derivatives', total: 706 } ] Which pipeline should you use?

Question59: What does IOPS stand for in database terminology?

Question60: Which of the following methods executes a database command? (mongo shell)

Question61: Given a movies collection where each document has the following structure: { _id: ObjectId('573a1390f29313caabcd60e4'), genres: [ 'Short', 'Comedy', 'Drama' ], title: 'The Immigrant', year: 1917, imdb: { rating: 7.8, votes: 4680, id: 8133 }, countries: [ 'USA' ] } Which of the following queries will find all the movies that have more votes than the year in which they were released?

Question62: A social media company needs to implement a data model that describes te relationships between users. When loading real data into the system, it turned out that one user has too many contacts to store them in the designated array. Instead of redesigning the entire system what pattern can you use?

Question63: Select the method that forces MongoDB to use a specific index.

Question64: How to correctly create a date (new object of Date type) in MongoDB?

Question65: What is the best practice in using the $match operator?

Question66: Given the following example document from an artists collection: { _id: 5, last_name: 'Maurer', first_name: 'Alfred', year_born: 1868, year_died: 1932, nationality: 'USA' } and the following index: db.artists.createIndex( { "last_name": 1, "nationality": 1 } ) How MongoDB will handle the query below?
db.artists.find( { "last_name": /^O./ } )

Question67: Select true statements about sorting & indexing performance.

Question68: Which of the following roles provides minimal privileges needed for backing up data in MongoDB?

Question69: Suppose you have a books collection with title field. Which of the following queries will return all books with a title ending in 'ian'?

Question70: Suppose you have a posts collection of documents in your social_app database.
What namespace are these documents stored in?

Question71: Select all true statements regarding to indexes.

Question72: Given a companies collection where each document has the following structure: { _id: ObjectId("52cdef7c4bab8bd675297efd"), name: 'ZoomInfo', homepage_url: 'http://www.zoominfo.com', blog_url: 'http://zoominfoblogger.wordpress.com/', twitter_username: 'ZoomInfo', founded_year: 2000, email_address: '' } Extract all companies from this collection that have the same Twitter username as the company name. Which query should you use?

Question73: Suppose you added the following index to a products collection: { product_category: 1 } Which of the following operations can potentially decrease performance?

Question74: Select true statements about data modeling in MongoDB.

Question75: Select all true statements regarding to replica sets in MongoDB.

Question76: There are some special databases in MongoDB that we cannot use to create a new database. Select those names.

Question77: Select all true statements about the $merge stage.

Question78: We have the following indexes: { name: 1, founded_year: 1 } { tag_list: 1, is_active: 1 } And the following documents: { _id: ObjectId("52cdef7c4bab8bd675297daa"), name: "Sparter", founded_year: 2007, tag_list: ["gaming", "game", "wow"], is_active: true }, { _id: ObjectId("52cdef7c4bab8bd675297da3"), name: "Yahoo!", founded_year: 1994, tag_list: ["search", "webmail"], is_active: true } Select true statement.

Question79: Select all true statement regarding to the MongoDB (BSON, JSON). (select 3)

Question80: Select all true statements about elections (replica set).

Question81: Which of the following read preference options may not result in out-of-date data?

Question82: We have a movies collection with the following document structure: { _id: ObjectId("573a1390f29313caabcd6223"), genres: [ 'Comedy', 'Drama', 'Family' ], title: 'The Poor Little Rich Girl', released: ISODate("1917-03-05T00:00:00.000Z"), year: 1917, imdb: { rating: 6.9, votes: 884, id: 8443 } } We need to extract all movies from this collection where genres does not include 'Romance'. Which query should we use?

Question83: Given a movies collection where each document has the following structure: { _id: ObjectId("573a1391f29313caabcd9264"), genres: [ 'Romance', 'Drama' ], title: 'The Divorcee', languages: [ 'English', 'French' ], year: 1930, imdb: { rating: 6.9, votes: 1740, id: 20827 }, countries: [ 'USA' ] } Which of the following queries will find all movies that have exactly 5 languages?

Question84: Which of the following commands will add a collection that is stored in JSON file to a MongoDB cluster?

Question85: Complete the sentence below.

Question86: What is MongoDB Compass?

Question87: Given a companies collection where each document has the following structure:
{ _id: ObjectId('61a8b90c6d5ce6a7d8fef95e'), name: 'Facebook', tag_list: ['facebook', 'college', 'students', 'network'], description: 'Social network' }
Which of the following commands will add new fields to the updated documents?

Question88: Why is MongoDB a NoSQL database?

Question89: Select true statements about the naming convention of collections in MongoDB.

Question90: Consider a one-to-one relationship observed between users and the users details. Basic information about application users is separated from detailed information. Which of the following are true about modeling this one-to-one relationship with the document model in MongoDB?